# -*- coding: utf-8 -*-

#import sys
#reload(sys)
#sys.setdefaultencoding("utf-8")

import scrapy
from itcast.items import ItcastItem

class Itcast01Spider(scrapy.Spider):
    name = 'itcast01'
    allowed_domains = ['http://www.itcast.cn']
    start_urls = ['http://www.itcast.cn/channel/teacher.shtml']

    def parse(self, response):
        #print(response.body.decode("UTF-8"))
        node_list = response.xpath("//div[@class='li_txt']")
        items = []
        for node in node_list:
            item = ItcastItem()
            item['name'] = node.xpath("./h3/text()").extract()[0]
            item['title'] = node.xpath("./h4/text()").extract()[0]
            item['info'] = node.xpath("./p/text()").extract()[0]
            items.append(item)
        # 返回给引擎 配合-o 输出items
        return items
    
